<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
	<div class="row">
		<div class="col-sm-12 search-collapse">
			<form id="role-form">
				<div class="select-list">
					<ul>
						<!--<li>
							归属平台：<select   name="deptId" id="productDeptId">
								<option value="">请选择归属平台</option>
							</select>

						</li>-->

						<li>
							录单员：<select   name="createBy" id="createBy">
                            <option value="">请选择录单员</option>
                        </select>
						</li>
						<!--<li>-->
							<!--产品：<select   name="productId" id="enterProductId">-->
							<!--<option value="">请选择产品</option>-->
						<!--</select>-->
						<!--</li>-->
						<li class="select-time">
							<label>注册时间： </label>
							<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
							<span>-</span>
							<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
						</li>
						<li>
							<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
							<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
						</li>
					</ul>
				</div>
			</form>
		</div>

		<div class="btn-group-sm" id="toolbar" role="group">
			<!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="enter:enter:add">-->
				<!--<i class="fa fa-plus"></i> 录入-->
			<!--</a>-->
			<!--<a class="btn btn-primary " onclick="checkAllEnterForm()" shiro:hasPermission="speed:speed:exportExcel">-->
				<!--<i class="fa fa-check"></i> 审核-->
			<!--</a>-->
			<a class="btn btn-warning" onclick="exportExcel()" shiro:hasPermission="speed:speed:exportExcel" >
				<i class="fa fa-download"></i> 导出
			</a>
		</div>

		<div class="col-sm-12 select-table table-striped">
			<table id="bootstrap-table" data-mobile-responsive="true"></table>
		</div>
	</div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script th:inline="javascript">
    // var editFlag = [[${@permission.hasPermi('enter:enter:edit')}]];
    // var removeFlag = [[${@permission.hasPermi('enter:enter:remove')}]];
    var prefix = ctx + "speed/speed";

    function exportExcel(){

        window.location.href =prefix+'/exportExcel?createBy='+$("#createBy").val()+"&beginTime="+$("#startTime").val()+"&endTime="+$("#endTime").val();
    }

    $(function () {
        // getAllProduct()
        // getAllDept()
        getAllEnterUser()
    })


    // 查询所有的产品名称
    // function getAllProduct() {
    //     $.ajax({
    //         type: "GET",
    //         url: prefix +'/allProduct',
    //         async: false,
    //         contentType : 'application/json;charset=utf-8',
    //         traditional:true,
    //         success : function(data) {
    //             for(var i=0;i<data.length;i++){
    //                 var html = "<option value='"+data[i].id+"'>"+data[i].productName + "</opinion>"
    //                 $("#enterProductId").append(html);
    //             }
    //         },
    //         error:function(e) {
    //             console.info(e);
    //         }
    //     });
    // }

    // // 获取所有的平台信息
    // function getAllDept() {
    //     $.ajax({
    //         type: "GET",
    //         url: prefix +'/allDeptT',
    //         async: false,
    //         contentType : 'application/json;charset=utf-8',
    //         traditional:true,
    //         success : function(data) {
    //             for(var i=0;i<data.length;i++){
    //                 var html = "<option value='"+data[i].deptId+"'>"+data[i].deptName + "</opinion>"
    //                 $("#productDeptId").append(html);
    //             }
    //         },
    //         error:function(e) {
    //             console.info(e);
    //         }
    //     });
    // }

    // 获取所有的录单员
    function getAllEnterUser() {
        $.ajax({
            type: "GET",
            url: prefix +'/getUserByRoeId',
            async: false,
            contentType : 'application/json;charset=utf-8',
            traditional:true,
            success : function(data) {
                for(var i=0;i<data.length;i++){
                    var html = "<option value='"+data[i].userId+"'>"+data[i].userName + "</opinion>"
                    $("#createBy").append(html);
                }
            },
            error:function(e) {
                console.info(e);
            }
        });
    }
    $(function() {
        var options = {
            url: prefix + "/list",
            uniqueId: "id",
            columns: [
                {
                    field: 'Number',
                    title: '序号',
                    formatter: function (value, row, index) {
                        return index + 1;
                    },
                },
                {
                    field: 'id',
                    title: '序号',
                    visible: false
                },
                {
                    field: 'userId',
                    title: '用户id',
                    visible: false
                },
                {
                    field: 'productId',
                    title: '产品id',
                    visible: false
                },
                {
                    field: 'today',
                    title: '日期',
                },
                {
                    field: 'userName',
                    title: '录单员',
                },
                // {
                //     field: 'productName',
                //     title: '产品名称',
                // },

                {
                    field: 'newCustomerCount',
                    title: '加新数',
                    // formatter:getNewCustomerCount,
                },
                {
                    field: 'oldCustomerCount',
                    title: '老客数',
                    // formatter:getOldCoustomerCount,
                },
                {
                    field: 'goodRecordCount',
                    title: '好评数',
                },
                {
                    field: 'integralCount',
                    title: '积分',
                    // formatter:getIntegralCount,
                },
                ]
        };
        $.table.init(options);
    });



    // // 审核订单信息
    // function checkAllEnterForm() {
    //     var rows = $.common.isEmpty($.table._option.uniqueId) ? $.table.selectFirstColumns() : $.table.selectColumns($.table._option.uniqueId);
    //     alert(rows)
    //     if (rows.length == 0) {
    //         $.modal.alertWarning("请至少选择一条记录");
    //         return;
    //     }
    //     $.modal.confirm("确认要审核选中的" + rows.length + "条数据吗?", function() {
    //         var url = prefix + "/checkAll";
    //         var data = { "ids": rows.join() };
    //         $.operate.submit(url, "post", "json", data);
    //     });
    // }

    // 获取对应的额产品的和录入人员的加新数
	function getNewCustomerCount(value,row,index) {
        var newCustomerCount;
        var beginTime = $("#startTime").val()
        var endTime = $("#endTime").val()
        $.ajax({
            type:"GET",
            url: prefix +'/getNewCoustomerCount',
            data:{
                "createBy":row.userId,
                "productId":row.productId,
				"beginTime":beginTime,
				"endTime":endTime
			},
            contentType: 'application/json;charset=utf-8',
            traditional: true,
            async:false,
            success : function(data){
                newCustomerCount = data;
            }
        });
        return newCustomerCount;
    }
    // 获取对应的额产品的和录入人员的老客户数
	function getOldCoustomerCount(value,row,index) {
        var odlCustomerCount;
        var beginTime = $("#startTime").val()
        var endTime = $("#endTime").val()
        $.ajax({
            type:"GET",
            url: prefix +'/getOldCoustomerCount',
            data:{
                "createBy":row.userId,
                "productId":row.productId,
                "beginTime":beginTime,
                "endTime":endTime
			},
            contentType: 'application/json;charset=utf-8',
            traditional: true,
            async:false,
            success : function(data){
                odlCustomerCount = data;
            }
        });
        return odlCustomerCount;
    }

    // 获取对应的额产品的和录入人员的积分
    function getIntegralCount(value,row,index) {
        var integralCount;
        var beginTime = $("#startTime").val()
        var endTime = $("#endTime").val()

        $.ajax({
            type:"GET",
            url: prefix +'/getIntegralCount',
            data:{
                "createBy":row.userId,
                "productId":row.productId,
                "goodRecord":row.goodRecord,
                "beginTime":beginTime,
                "endTime":endTime
            },
            contentType: 'application/json;charset=utf-8',
            traditional: true,
            async:false,
            success : function(data){
                integralCount = data;
            }
        });
        return integralCount;
    }







</script>
</body>
</html>